//
//  RepayTableViewCell.m
//  51易借
//
//  Created by 张睿 on 2017/8/30.
//  Copyright © 2017年 张睿. All rights reserved.
//

#import "RepayTableViewCell.h"


@implementation RepayTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
    }
    
    return self;
}


- (void)setupUI{
    
    self.backgroundColor = [UIColor whiteColor];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    UILabel * titleLabel = [UILabel new];
    
    titleLabel.textColor = ColorWithRGB(0x303c41);
    titleLabel.font = [UIFont systemFontOfSize:13 * SCREENH6];
    titleLabel.textAlignment = NSTextAlignmentLeft;
//    titleLabel.text = @"借款编号";
    
    self.titleLabel = titleLabel;
    
    [self.contentView addSubview:self.titleLabel];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.contentView).offset(15 * SCREENH6);
        make.centerY.mas_equalTo(self.contentView);
    }];
    
    
    UIButton * troubleButton = [UIButton new];
    
    [troubleButton setImage:[UIImage imageNamed:@"问号"] forState:UIControlStateNormal];
    [troubleButton addTarget:self action:@selector(didTroubleButton) forControlEvents:UIControlEventTouchUpInside];
    
    self.troubleButton = troubleButton;
    
    [self.contentView addSubview:self.troubleButton];
    
    [self.troubleButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.titleLabel.mas_trailing).offset(5 * SCREENH6);
        make.centerY.mas_equalTo(self.titleLabel);
        make.width.height.mas_equalTo(17.5 * SCREENH6);
    }];
    
    
    UILabel * valueLabel = [UILabel new];
    
    valueLabel.textColor = ColorWithRGB(0x7f7f7f);
    valueLabel.font = [UIFont systemFontOfSize:13 * SCREENH6];
    valueLabel.textAlignment = NSTextAlignmentRight;
    valueLabel.text = @"YY123456";
    
    self.valueLabel = valueLabel;
    
    [self.contentView addSubview:self.valueLabel];
    
    [self.valueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(self.contentView).offset(-40 * SCREENH6);
        make.centerY.mas_equalTo(self.contentView);
     }];
    
    
    UIButton * watchButton = [UIButton new];
    
    [watchButton setTitle:@"查看" forState:UIControlStateNormal];
    [watchButton setTitleColor:TOTAL_COLOR forState:UIControlStateNormal];
    watchButton.titleLabel.font = [UIFont systemFontOfSize:13 * SCREENH6];
    [watchButton addTarget:self action:@selector(didWatchButton) forControlEvents:UIControlEventTouchUpInside];
//    [watchButton setBackgroundColor:[UIColor redColor]];
    
    self.watchButton = watchButton;
    
    [self.contentView addSubview:self.watchButton];
    
    [self.watchButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(self.valueLabel);
        make.centerY.mas_equalTo(self.titleLabel);
        make.height.mas_equalTo(15 * SCREENH6);
        make.width.mas_equalTo(35 * SCREENH6);
    }];
}


- (void)didTroubleButton{
    
//    NSLog(@"点击问号");
    
    [[NSNotificationCenter defaultCenter] postNotificationName:@"showServiceView" object:nil];
}


- (void)didWatchButton{
    
//    NSLog(@"点击查看");
    [[NSNotificationCenter defaultCenter] postNotificationName:@"pushWebView" object:nil];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
